package org.grizz.game.input;

import java.util.LinkedList;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputAdapter;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.Screen;

public class ScreenSwitcherInputProcessor extends InputAdapter {
	private Game game;
	private LinkedList<Screen> screens;

	public ScreenSwitcherInputProcessor(Game game) {
		this.game = game;
		screens = new LinkedList<Screen>();
	}
	
	public void addScreen(Screen screen) {
		screens.add(screen);
	}

	@Override
	public boolean keyDown(int keycode) {
		if(Keys.SPACE == keycode) {
			Screen screenToSet = screens.poll();
			if(screenToSet != null) {
				game.setScreen(screenToSet);
			}
			screens.addLast(screenToSet);
			
			return true;
		}
		
		return false;
	}
}
